package com.yanqu.road.server.manger.recharge;

import com.yanqu.road.entity.enums.eChannelType;
import com.yanqu.road.entity.recharge.RechargeMultipleInfo;
import com.yanqu.road.logic.bussiness.recharge.RechargeBussiness;
import com.yanqu.road.server.GameServer;
import com.yanqu.road.server.TempMgr;
import com.yanqu.road.server.manger.ServerListMgr;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class RechargeMgr extends TempMgr {

    //mallId
    static Map<Integer, RechargeMultipleInfo> multipleInfoMap;

    @Override
    public boolean reloadConfig() throws Exception {
        int channelId = ServerListMgr.getChannelId(GameServer.getInstance().getServerId());
        multipleInfoMap = RechargeBussiness.getRechargeMultipleInfoList(channelId);
        return true;
    }

    @Override
    public boolean reloadData() throws Exception {
        return true;
    }

    @Override
    public boolean init() throws Exception {
        return reload();
    }

    @Override
    public boolean stop() {
        return false;
    }

    public static RechargeMultipleInfo getMultipleInfoMap(int mallId) {
        if(multipleInfoMap == null){
            return null;
        }
        return multipleInfoMap.get(mallId);
    }

    public static List<RechargeMultipleInfo> getMultipleInfoList() {
        if(multipleInfoMap == null){
            return new ArrayList<>();
        }
        return new ArrayList<>(multipleInfoMap.values());
    }

    /**
     * 是否使用新的首充多倍机制
     */
    public static boolean isUseNewMultiple(){
        int channelId = ServerListMgr.getChannelId(GameServer.getInstance().getServerId());
        if(channelId == eChannelType.VN.getValue() ||
            channelId == eChannelType.VNTest.getValue() ||
             channelId == eChannelType.VNExperience.getValue() ||
                channelId == eChannelType.VNVersion.getValue() ||
                    channelId == eChannelType.VNInnerTest.getValue() ||
                    channelId == eChannelType.VNYunCe.getValue()){
            return true;
        }
        //增加国际服多倍充值
        if(channelId == eChannelType.US.getValue() ||
                channelId == eChannelType.UK.getValue() ||
                channelId == eChannelType.Thailand.getValue() ||
                channelId == eChannelType.ThailandTest.getValue() ||
                channelId == eChannelType.ThailandExperience.getValue() ||
                channelId == eChannelType.ThailandInnerTest.getValue()){
            return true;
        }
        return false;
    }
}
